Skip to content

feat: improve Application Insights logging and telemetry handling#753

Merged
Roopan-Microsoft merged 18 commits intodevfrom
PSL-US-35960
Mar 25, 2026
Merged

feat: improve Application Insights logging and telemetry handling#753
Roopan-Microsoft merged 18 commits intodevfrom
PSL-US-35960

Conversation

@AjitPadhi-Microsoft
Copy link
Copy Markdown
Contributor

@AjitPadhi-Microsoft AjitPadhi-Microsoft commented Mar 3, 2026

Purpose

  • This pull request introduces comprehensive improvements for observability and logging in the backend application, focusing on Application Insights integration, enhanced logging configuration, and richer telemetry for key user and system events. The changes also improve error handling by switching to exception-level logging and add event tracking for important workflow steps. Additionally, infrastructure files are updated to support these new observability features through environment variables and deployment configuration.

Does this introduce a breaking change?

  • Yes
  • No

Golden Path Validation

  • I have tested the primary workflows (the "golden path") to ensure they function correctly without errors.

Deployment Validation

  • I have validated the deployment process successfully and all services are running as expected with this change.

What to Check

Verify that the following are valid

  • ...

Other Information

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds Azure Application Insights (via Azure Monitor OpenTelemetry) initialization to the backend entrypoint so the service can emit telemetry when an Application Insights connection string is provided.

Changes:

  • Import configure_azure_monitor and conditionally configure Azure Monitor at startup based on APPLICATIONINSIGHTS_CONNECTION_STRING.
  • Add startup log lines indicating whether Application Insights was configured.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +41 to +49
# Check if the Application Insights Instrumentation Key is set in the environment variables
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
# Configure Application Insights if the Instrumentation Key is found
configure_azure_monitor(connection_string=instrumentation_key)
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comments/log messages and variable name refer to an "Instrumentation Key", but the code is reading APPLICATIONINSIGHTS_CONNECTION_STRING and passes it as connection_string. Please rename instrumentation_key to something like appinsights_connection_string and update the comments/messages to consistently refer to a connection string (or change the env var if you truly intend to use an instrumentation key).

Suggested change
# Check if the Application Insights Instrumentation Key is set in the environment variables
instrumentation_key = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if instrumentation_key:
# Configure Application Insights if the Instrumentation Key is found
configure_azure_monitor(connection_string=instrumentation_key)
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
# Check if the Application Insights connection string is set in the environment variables
appinsights_connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
if appinsights_connection_string:
# Configure Application Insights if the connection string is found
configure_azure_monitor(connection_string=appinsights_connection_string)
logging.info("Application Insights configured with the provided connection string")
else:
# Log a warning if the connection string is not found
logging.warning("No Application Insights connection string found. Skipping configuration")

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +49
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file defines a module logger (logger = logging.getLogger(__name__)), but these new lines log via the root logging module. Please use the module logger (logger.info / logger.warning) so log records have the correct logger name and can be filtered/structured consistently with the rest of the file.

Suggested change
logging.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logging.warning("No Application Insights Instrumentation Key found. Skipping configuration")
logger.info("Application Insights configured with the provided Instrumentation Key")
else:
# Log a warning if the Instrumentation Key is not found
logger.warning("No Application Insights Instrumentation Key found. Skipping configuration")

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@AjitPadhi-Microsoft AjitPadhi-Microsoft changed the title fix: fixed app insights logging issue feat: improve Application Insights logging and telemetry handling Mar 13, 2026
@Roopan-Microsoft Roopan-Microsoft merged commit 9254d87 into dev Mar 25, 2026
6 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 2.3.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants